#include <vector>
#include <algorithm>
#include <iostream>
#include <climits>

using namespace std;

/*
Link: http://www.usaco.org/index.php?page=viewproblem2&cpid=1203
Level: Bronze
*/

void solution(const vector<int> &log, int sum) {
  int result = 0;

  for (int r = log.size(); r > 0; --r) {
    /*
      r - The groups we can divide the log into.

      Example
      log: [a1, a2, a3, a4, a5]

      If log could be transformed to [n, n, n],
      (a1 + a2 + a3 + a4 + a5) % 3 must be zero.

      If log could be transformed to [m, m],
      (a1 + a2 + a3 + a4 + a5) % 2 must be zero.
    */
    if (sum % r == 0) {
      int target = sum / r;
      int prefix = 0;
      bool is_ok = true;

      for (int j = 0; j < log.size(); ++j) {
        prefix += log[j];

        if (prefix > target) {
          // We cannot sum up part of the log array to target.
          // Try the next division.
          is_ok = false;
          break;
        }

        if (prefix == target) {
          // We find a subsequece that sums up to target. Try to
          // find the next group.
          prefix = 0;
        }
      }

      if (is_ok) {
        // The first time we get a match, it's the minimum steps
        // that makes all elements equal.
        cout << log.size() - r << endl;
        return;
      }
    }
  }
}

int main(int argc, char const *argv[])
{
  int tests = 0;
  cin >> tests;

  while (tests != 0) {

    int records = 0;
    cin >> records;

    vector<int> tmp(records, 0);
    int prefixSum = 0;
    
    for (int i = 0; i < records; ++i) {
      cin >> tmp[i];
      prefixSum += tmp[i];
    }
    
    solution(tmp, prefixSum);

    --tests;
  }
  return 0;
}
